Skip to content

chore: rework mutagen controller, add polling #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 2, 2025

Conversation

deansheather
Copy link
Member

  • Use locks during operations for daemon process consistency
  • Use a state model for UI rendering
  • Use events to signal state changes
  • Fix some tooltip problems that arise from polling

- Use locks during operations for daemon process consistency
- Use a state model for UI rendering
- Use events to signal state changes
- Fix some tooltip problems that arise from polling
@deansheather deansheather requested a review from spikecurtis April 1, 2025 01:46
_state = state;
// Since the event handlers could block (or call back the
// CredentialManager and deadlock), we run these in a new task.
if (StateChanged == null) return;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need to check if the state has actually changed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided not to implement equality for the state type because I would also need to implement equality for the sync session model (and all of it's sub types) which seems like a lot. I don't think there's any side effects of calling this every time it changes though

// Since the event handlers could block (or call back the
// CredentialManager and deadlock), we run these in a new task.
if (StateChanged == null) return;
Task.Run(() => { StateChanged?.Invoke(this, state); });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are Events threadsafe? If we start this in another task, could it be modified under us in a way that breaks stuff?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll copy the EventHandler to a variable before calling it, which I believe makes it thread safe

@deansheather deansheather requested a review from spikecurtis April 2, 2025 02:20
Copy link
Collaborator

@spikecurtis spikecurtis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@deansheather deansheather requested a review from spikecurtis April 2, 2025 05:58
@deansheather deansheather merged commit 1193e4b into dean/sync-wiring Apr 2, 2025
@deansheather deansheather deleted the dean/mutagen-controller-rework branch April 2, 2025 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants